
#include "UIQuad.h"

#include <SDL2/SDL_opengl.h>

#include <ALittleClient/LogSystem/LogSystem.h>

namespace ALittle
{

UIQuad::UIQuad()
: m_visible(true)
, m_top(0.0f), m_bottom(0.0f)
, m_left(0.0f), m_right(0.0f)
, m_red(1.0f), m_green(1.0f), m_blue(1.0f), m_alpha(1.0f)
{ }

UIQuad::~UIQuad()
{
}

void UIQuad::SetVisible(bool visible)
{
	m_visible = visible;
}

void UIQuad::SetX(float x)
{
	float width = m_right - m_left;

	m_left = x;
	m_right = m_left + width;
}

void UIQuad::SetY(float y)
{
	float height = m_bottom - m_top;

	m_top = y;
	m_bottom = m_top + height;
}

void UIQuad::SetWidth(float width)
{
	m_right = m_left + width;
}

void UIQuad::SetHeight(float height)
{
	m_bottom = m_top + height;
}

void UIQuad::SetRed(float red)
{
	m_red = red;
}

void UIQuad::SetGreen(float green)
{
	m_green = green;
}

void UIQuad::SetBlue(float blue)
{
	m_blue = blue;
}

void UIQuad::SetAlpha(float  alpha)
{
	m_alpha = alpha;
}

void UIQuad::Render()
{
	if (!m_visible) return;

	glBegin(GL_QUADS);
		glColor4f(m_red, m_green, m_blue, m_alpha);
		glVertex3f( m_left,  m_top, 0.0f );			/* Top Left */
		glVertex3f( m_right, m_top, 0.0f );			/* Top Right */
		glVertex3f( m_right, m_bottom, 0.0f );		/* Bottom Right */
		glVertex3f( m_left,  m_bottom, 0.0f );		/* Bottom Left */
	glEnd();
}

} // ALittle
